<template>
    <ul>
        <div class="timeline-item-line"></div>
        <li class="timeline-item parent">
            <!-- <div class="timeline-item-line"></div> -->
            <img class="timeline-item-node" src="../../assets/8512345/time.png" alt />
            <div class="timeline-item-wrapper">
                <!---->
                <div class="timeline-item-content item-center">
                    <div class="top-title">{{title||'-'}}</div>
                    <slot name = "titleButton"></slot>
                </div>
            </div>
        </li>
        <li class="timeline-item" v-for="(item,index) in list" :key="index">
            <!-- <div class="timeline-item-line"></div> -->
            <img class="timeline-item-node" src="../../assets/pigeonholes/timing_icon.png" alt />
            <div class="timeline-item-wrapper">
                <!---->
                <div class="timeline-item-timestamp">{{initTime(item.handleTime)}}</div>
                <div class="timeline-item-content">
                    <img src="../../assets/pigeonholes/triangle_icon.png" alt />
                    <div class="item-content-title pad12">{{item.statusName||'-'}}</div>
                    <div class="item-content-main pad12">{{item.content||'-'}}</div>
                    <div class="fujian" v-if="item.sysAttrFiles&&item.sysAttrFiles.length>0">
                        <span>附件：</span>
                            <i v-if="loading" class="el-icon-loading"></i>
                            <div
                                :class="loading?'width0':''"
                                v-for="(it,ind) in item.sysAttrFiles"
                                :key="ind"
                            >
                                <!-- <video :onloadstart="handleImageLoaded('video',123123123)" src="https://www.w3school.com.cn/i/movie.ogg">您的浏览器不支持播放器</video> -->
                                <video
                                    v-if="(it.type||'').includes('video')"
                                    :onloadstart="handleImageLoaded('video',it.fileSavePath)"
                                    @click="onShowImg('video',it.fileSavePath)"
                                    :src="it.fileSavePath"
                                >您的浏览器不支持播放器</video>
                                <img
                                    v-else
                                    :onload="handleImageLoaded('img',it.fileSavePath)"
                                    style="white-space:nowrap"
                                    @click="onShowImg('img',it.fileSavePath)"
                                    :src="it.fileSavePath"
                                    alt="点击查看附件"
                                    title="点击查看附件"
                                />
                            </div>
                    </div>
                </div>
            </div>
        </li>
        <div v-if="!!currentImg" @click="toggleMaskImg" class="img-mask">
            <video
                v-if="currentType=='video'"
                :src="currentImg"
                controls="controls"
            >您的浏览器不支持播放器</video>
            <img v-else :src="currentImg" />
        </div>
    </ul>
</template>
<script>
import { getTimeStr } from "../../utils";
export default {
    props: {
        list: Array,
        title: String
    },
    data() {
        return {
            currentType: "img", //当前放大的类别
            currentImg: "", //当前放大的图片
            loading: true, //当前是否在加载中
        };
    },
    mounted() {},
    destroyed() {},
    methods: {
      handleImageLoaded(type, url){
        this.loading=false;
      },
        initTime(time) {
            if (time) {
                return getTimeStr(time) || "";
            } else {
                return "-";
            }
        },
        onShowImg(type, url) {
          console.log(type, url);
            this.currentType = type;
            this.currentImg = url;
        },
        /**
         * 关闭放大图片
         */
        toggleMaskImg() {
            this.currentImg = "";
        }
    }
};
</script>

<style lang = "scss" scoped>
ul {
    width: 100%;
    position: relative;
    padding-left: 10px;
    box-sizing: border-box;
    min-height: 100%;
    .timeline-item-line {
        left: 16px;
    }
}
.timeline-item {
    position: relative;
    min-height: 50px;
    padding-bottom: 20px;
    font-size: 12px;
}
.timeline-item-line {
    position: absolute;
    left: 6px;
    height: 100%;
    border-left: 2px solid #eaeaea;
}
.timeline-item-node {
    width: 14px;
    position: absolute;
    background-color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.timeline-item-wrapper {
    position: relative;
    padding-left: 30px;
    top: -36px;
    width: 100%;
    box-sizing: border-box;
}
.timeline-item-timestamp {
}
.timeline-item-content {
    position: relative;
    padding: 12px 0;
    border: 1px solid #abd0ff;
    border-radius: 5px;
    box-sizing: border-box;
    margin-top: 10px;
    background-color: #fafcff;
    .pad12 {
        padding: 0 12px;
    }
    .item-content-title {
        color: #004293;
        font-size: 14px;
        margin-bottom: 10px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .top-title{
        color: #004293;
        font-size: 14px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .item-content-main {
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    > img {
        position: absolute;
        left: -10px;
    }
}
.parent {
    padding-bottom: 30px;
    .timeline-item-node {
        width: 32px;
    }
    .timeline-item-wrapper {
        top: 0;
        padding-top: 5px;
    }
    .timeline-item-content {
        padding: 0;
        border: none;
        margin-top: 0;
        background-color: #fff;
        .item-content-title {
            padding-left: 4px;
            font-size: 16px;
            -webkit-line-clamp: 1;
        }
    }
    .timeline-item-node {
        left: -9px;
    }
}
.fujian {
    padding: 12px 12px 0;
    margin-top: 10px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-direction: row;
    img,
    video {
        margin-right: 8px;
        width: 38px;
        max-width: 45px;
        max-height: 45px;
        display: inline-block;
        cursor: pointer;
        text-align: center
    };
    i{
      height: 100%;
    }
}
.img-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    img,video {
        max-width: 60vw;
        max-height: 60vh;
    }
}
.width0{
  display: inline-block;
  width: 0;
  overflow:hidden
}
</style>